$(function(e) {
    var d = e.separator || "&";
    var c = e.spaces === false ? false: true;
    var a = e.suffix === false ? "": "[]";
    var g = e.prefix === false ? false: true;
    var b = g ? e.hash === true ? "#": "?": "";
    var f = e.numbers === false ? false: true;
    jQuery.query = new
    function() {
        var h = function(m, l) {
            return m != undefined && m !== null && ( !! l ? m.constructor == l: true)
        };
        var i = function(r) {
            var l, q = /\[([^[]*)\]/g,
            n = /^([^[]+)(\[.*\])?$/.exec(r),
            o = n[1],
            p = [];
            while (l = q.exec(n[2])) {
                p.push(l[1])
            }
            return [o, p]
        };
        var k = function(s, r, q) {
            var t, p = r.shift();
            if (typeof s != "object") {
                s = null
            }
            if (p === "") {
                if (!s) {
                    s = []
                }
                if (h(s, Array)) {
                    s.push(r.length == 0 ? q: k(null, r.slice(0), q))
                } else {
                    if (h(s, Object)) {
                        var n = 0;
                        while (s[n++] != null) {}
                        s[--n] = r.length == 0 ? q: k(s[n], r.slice(0), q)
                    } else {
                        s = [];
                        s.push(r.length == 0 ? q: k(null, r.slice(0), q))
                    }
                }
            } else {
                if (p && p.match(/^\s*[0-9]+\s*$/)) {
                    var m = parseInt(p, 10);
                    if (!s) {
                        s = []
                    }
                    s[m] = r.length == 0 ? q: k(s[m], r.slice(0), q)
                } else {
                    if (p) {
                        var m = p.replace(/^\s*|\s*$/g, "");
                        if (!s) {
                            s = {}
                        }
                        if (h(s, Array)) {
                            var l = {};
                            for (var n = 0; n < s.length; ++n) {
                                l[n] = s[n]
                            }
                            s = l
                        }
                        s[m] = r.length == 0 ? q: k(s[m], r.slice(0), q)
                    } else {
                        return q
                    }
                }
            }
            return s
        };
        var j = function(l) {
            var m = this;
            m.keys = {};
            if (l.queryObject) {
                jQuery.each(l.get(),
                function(n, o) {
                    m.SET(n, o)
                })
            } else {
                jQuery.each(arguments,
                function() {
                    var n = "" + this;
                    n = n.replace(/^[?#]/, "");
                    n = n.replace(/[;&]$/, "");
                    if (c) {
                        n = n.replace(/[+]/g, " ")
                    }
                    jQuery.each(n.split(/[&;]/),
                    function() {
                        var o = decodeURIComponent(this.split("=")[0] || "");
                        var p = decodeURIComponent(this.split("=")[1] || "");
                        if (!o) {
                            return
                        }
                        if (f) {
                            if (/^[+-]?[0-9]+\.[0-9]*$/.test(p)) {
                                p = parseFloat(p)
                            } else {
                                if (/^[+-]?[0-9]+$/.test(p)) {
                                    p = parseInt(p, 10)
                                }
                            }
                        }
                        p = (!p && p !== 0) ? true: p;
                        if (p !== false && p !== true && typeof p != "number") {
                            p = p
                        }
                        m.SET(o, p)
                    })
                })
            }
            return m
        };
        j.prototype = {
            queryObject: true,
            has: function(l, m) {
                var n = this.get(l);
                return h(n, m)
            },
            GET: function(m) {
                if (!h(m)) {
                    return this.keys
                }
                var l = i(m),
                n = l[0],
                p = l[1];
                var o = this.keys[n];
                while (o != null && p.length != 0) {
                    o = o[p.shift()]
                }
                return typeof o == "number" ? o: o || ""
            },
            get: function(l) {
                var m = this.GET(l);
                if (h(m, Object)) {
                    return jQuery.extend(true, {},
                    m)
                } else {
                    if (h(m, Array)) {
                        return m.slice(0)
                    }
                }
                return m
            },
            SET: function(m, r) {
                var o = !h(r) ? null: r;
                var l = i(m),
                n = l[0],
                q = l[1];
                var p = this.keys[n];
                this.keys[n] = k(p, q.slice(0), o);
                return this
            },
            set: function(l, m) {
                return this.copy().SET(l, m)
            },
            REMOVE: function(l) {
                return this.SET(l, null).COMPACT()
            },
            remove: function(l) {
                return this.copy().REMOVE(l)
            },
            EMPTY: function() {
                var l = this;
                jQuery.each(l.keys,
                function(m, n) {
                    delete l.keys[m]
                });
                return l
            },
            load: function(l) {
                var n = l.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
                var m = l.replace(/^.*?[?](.+?)(?:#.+)?$/, "$1");
                return new j(l.length == m.length ? "": m, l.length == n.length ? "": n)
            },
            empty: function() {
                return this.copy().EMPTY()
            },
            copy: function() {
                return new j(this)
            },
            COMPACT: function() {
                function l(o) {
                    var n = typeof o == "object" ? h(o, Array) ? [] : {}: o;
                    if (typeof o == "object") {
                        function m(r, p, q) {
                            if (h(r, Array)) {
                                r.push(q)
                            } else {
                                r[p] = q
                            }
                        }
                        jQuery.each(o,
                        function(p, q) {
                            if (!h(q)) {
                                return true
                            }
                            m(n, p, l(q))
                        })
                    }
                    return n
                }
                this.keys = l(this.keys);
                return this
            },
            compact: function() {
                return this.copy().COMPACT()
            },
            toString: function() {
                var n = 0,
                r = [],
                q = [],
                m = this;
                var o = function(s) {
                    s = s + "";
                    if (c) {
                        s = s.replace(/ /g, "+")
                    }
                    return encodeURIComponent(s)
                };
                var l = function(s, t, u) {
                    if (!h(u) || u === false) {
                        return
                    }
                    var v = [o(t)];
                    if (u !== true) {
                        v.push("=");
                        v.push(o(u))
                    }
                    s.push(v.join(""))
                };
                var p = function(t, s) {
                    var u = function(v) {
                        return ! s || s == "" ? [v].join("") : [s, "[", v, "]"].join("")
                    };
                    jQuery.each(t,
                    function(v, w) {
                        if (typeof w == "object") {
                            p(w, u(v))
                        } else {
                            l(q, u(v), w)
                        }
                    })
                };
                p(this.keys);
                if (q.length > 0) {
                    r.push(b)
                }
                r.push(q.join(d));
                return r.join("")
            }
        };
        return new j(location.search, location.hash)
    }
} );
$(function() {});
var bottom_cart = bottom_cart || {};
bottom_cart.active_group_id = 1;
bottom_cart.opened = false;
bottom_cart.load = function(b) {
    var a = no_cache_url(get_entry_url() + "/cart/bottomCart");
    $.get(a, {},
    function(c) {
        if ($("#bottom-cart").size() >= 1) {
            $("#bottom-cart").remove();
        }
        $("body").append(c);
        $(window).scroll();
        if (typeof b != "undefined") {
            b(c);
        }
    });
};
bottom_cart.clear = function(b) {
    var a = no_cache_url(get_entry_url() + "/cart/clearCart");
    $.get(a, {},
    function(c) {
        if (typeof b != "undefined") {
            b(c);
        }
    });
};

bottom_cart.add_effect = function(b) {
    if (typeof b != "undefined") {
        var a = $(window).height() - (b.offset().top - $(window).scrollTop()) - 100;
        if (a < 200) {
            a = 200
        }
        $("#cart-add-effect").css({
            left: b.offset().left,
            bottom: a
        })
    }
    $("#cart-add-effect").show().animate({
        bottom: "10px",
        opacity: 0
    },
    800,
    function() {
        $("#cart-add-effect").css({
            bottom: "200px",
            opacity: 1,
            display: "none"
        })
    })
};
$(function() {
   // if (!ma || ma != "restaurant/show" || tab != "menu") {
	/*if (!ma || ma != "restaurant/show" || tab != "menu") {
        return false
    }
    var a = $('<img class="loading-after-click" src="../images/loading.gif" />').appendTo("body").css({
        position: "absolute",
        zIndex: "99999",
        display: "none"
    }); */(function() {
        var f = function() {
            if (2>1) {
                var i = false;
                if (!i) {
                    $("#modal-cart-not-the-same-restaurant").modal({
                        keyboard: true,
                        backdrop: "static"
                    });
                    i = true
                }
                $("#modal-cart-not-the-same-restaurant").modal("show");
                $("#modal-cart-not-the-same-restaurant .btn.complete").click(function() {
                    $("#modal-cart-not-the-same-restaurant").modal("hide")
                });
                $("#modal-cart-not-the-same-restaurant .btn.clear-cart").click(function() {
                    bottom_cart.clear(function() {
                        bottom_cart.load(function(j) {
                            $("#topbar-cart-food-num").html("(空)")
                        })
                    });
                    $("#modal-cart-not-the-same-restaurant").modal("hide");
                });
                return false;
            }
            return false;
        };
        var h = $.query.get("fid");
        if (h) {
            $("body").scrollTo($("#food-" + h).offset().top - 40)
        }
        bottom_cart.load(function(i) {
            $(".food-item, .image-food-item").removeClass("selected");
            $("#bottom-cart .food-line").each(function(j) {
                var k = $(this).attr("rel");
                $("#food-" + k).addClass("selected")
            });
            f()
        });
        $(".line-brief").live("click",function() {
            if ($(".line-detail").is(":visible")) {
                bottom_cart.close();
            } else {
                bottom_cart.open();
            }
        });
        $(".col-group").live("click",
        function() {
            if ($(this).hasClass("active")) {
                bottom_cart.close();
                return false
            }
            var i = $(this).attr("rel");
            bottom_cart.active_group_id = i;
            bottom_cart.open();
            return false
        });
        $(".col-add-group").live("click",
        function() {
            _gaq.push(["_trackEvent", "add_cart_group", "click", "1"]);
            var i = 1;
            $(".col-group").each(function(j) {
                var k = parseInt($(this).attr("rel"));
                if (k > i) {
                    i = k
                }
            });
            bottom_cart.active_group_id = i + 1;
            $("#cart-detail-table-empty").clone().appendTo("#bottom-cart .line-detail").attr("id", "cart-detail-table-" + bottom_cart.active_group_id);
            $(this).html(bottom_cart.active_group_id + "号篮子").removeClass("col-add-group").addClass("col-group active").attr("id", "col-group-" + bottom_cart.active_group_id).attr("rel", bottom_cart.active_group_id);
            bottom_cart.open(bottom_cart.active_group_id);
            return false
        });
        $(".cart-close").live("click",
        function() {
            bottom_cart.close();
            return false
        });
        var e = function(i, j) {
            bottom_cart.load(function(l) {
                if (bottom_cart.opened) {
                    bottom_cart.open();
                }
                $(".food-item, .image-food-item").removeClass("selected");
                $("#bottom-cart .food-line").each(function(m) {
                    var n = $(this).attr("rel");
                    $("#food-" + n).addClass("selected")
                });
                var k = cart.total_quantity > 0 ? cart.total_quantity: "空";
                $("#topbar-cart-food-num").html("(" + k + ")");
                if (typeof j != "undefined") {
                    j(l)
                }
            })
        };
        var g = function(j) {
            var i = j.offset().top;
            a.css({
                top: i,
                left: j.offset().left + j.width() + 18
            }).show()
        };
        $(".food-action.add, .food-action.book").live("click",
        function() {
            if (!f()) {
                return false
            }
            var j = no_cache_url(get_entry_url() + "/cart/add");
            var i = $(this).attr("entity_id");
            var l = bottom_cart.active_group_id;
            var k = 0;
            var m = $(this);
            g($(this));
            $.get(j, {
                entity_id: i,
                parent_entity_id: k,
                group_id: l
            },
            function(n) {
                e(n,
                function(o) {
                    bottom_cart.add_effect(m)
                });
                a.hide()
            });
            return false
        });
        $("body").click(function(i) {
            if (! ($(i.target).parents().is(".add-to-box"))) {
                $(".add-to-box").hide()
            }
        });
        $(".food-action.add-to").live("click",
        function() {
            if (!f()) {
                return false
            }
            var m = $(this).offset().left + $(this).width() + 5;
            var l = $(this).offset().top;
            $(".add-to-box").css({
                top: l,
                left: m
            }).show();
            var i = $(this).attr("entity_id");
            var k = bottom_cart.active_group_id;
            var j = no_cache_url(get_entry_url() + "/cart/addToCart");
            $.get(j, {
                entity_id: i,
                group_id: k
            },
            function(n) {
                if ($(".add-to-box").size() >= 1) {
                    $(".add-to-box").remove()
                }
                $("body").append(n);
                $(".add-to-box").css({
                    top: l,
                    left: m
                }).show()
            });
            return false
        });
        $(".add-to-box li").live("click",
        function() {
            var i = $(this).attr("entity_id");
            var l = $(this).attr("parent_entity_id");
            var k = bottom_cart.active_group_id;
            var j = no_cache_url(get_entry_url() + "/cart/add");
            g($(this));
            var m = $(this);
            $.get(j, {
                entity_id: i,
                parent_entity_id: l,
                group_id: k
            },
            function(n) {
                e(n,
                function(o) {
                    bottom_cart.add_effect(m);
                    a.hide();
                    $(".add-to-box").remove()
                })
            })
        });
        $(".cart-action").live("click",
        function() {
            g($(this));
            var i = no_cache_url($(this).attr("href"));
            $.get(i, {},
            function(j) {
                e(j,
                function(k) {
                    a.hide()
                })
            });
            return false
        });
        $(".cart-btn").live("click",
        function() {
            if (cart.deliver_amount_message !== "") {
                $("#modal-deliver-amount").modal({
                    keyboard: true,
                    backdrop: "static"
                });
                $("#modal-deliver-amount .modal-body").html("<h3>" + cart.deliver_amount_message + "</h3");
                $("#modal-deliver-amount").modal("show");
                $("#modal-deliver-amount .btn.complete").live("click",
                function() {
                    $("#modal-deliver-amount").modal("hide");
                    return false
                });
                return false
            }
            if ($(".btn.see-phone").size() >= 1) {
                $(".btn.see-phone").click();
                return false
            }
            window.location = get_entry_url() + "/cart/checkout";
            return false
        });
        var d = $(".right-fold .row");
        var c = $(window).height();
        var b = d.offset().top;
        $(window).resize(function() {
            c = $(window).height()
        });
        $(window).scroll(function() {
            var l = d.height();
            var i = b + l;
            var m = $("#bottom-cart");
            var k = $(window).scrollTop();
            var j = c + k - i - 1;
            if (j > 0) {
                m.css({
                    bottom: j
                })
            } else {
                m.css({
                    bottom: 0
                })
            }
        });
        $(".order-item").live("keyup",
        function(n) {
            var j = $(this).val();
            var o = $(this).parent().parent().attr("rel");
            var k = no_cache_url(get_entry_url() + "/cart/set");
            var i = $(this).attr("entity_id");
            var m = bottom_cart.active_group_id;
            var l = 0;
            $.ajax({
                type: "POST",
                url: k,
                data: {
                    item_num: j,
                    food_id: o
                }
            });
            $.get(k, {
                entity_id: i,
                parent_entity_id: l,
                group_id: m
            },
            function(p) {
                e(p,
                function(q) {})
            });
            return false
        })
    })()
});
$(function() {
    if (!ma || ma != "restaurant/show") {
        return false
    } (function() {
        var a = false;
        $(".btn.see-phone").click(function() {
            if (!a) {
                $("#modal-see-phone").modal({
                    keyboard: true,
                    backdrop: "static"
                });
                a = true
            }
            $("#modal-see-phone").modal("show");
            $("#modal-see-phone .btn.complete").click(function() {
                $("#modal-see-phone").modal("hide")
            });
            return false
        })
    })(); (function() {})(); (function() {
        var b = get_entry_url() + "/restaurant/isFavored";
        $.get(no_cache_url(b), {
            entry_id: dianexia.entry_id,
            restaurant_id: restaurant_id
        },
        function(d) {
            if (d >= 1) {
                $(".favor-icon").show();
                $(".un-favor-restaurant").show()
            } else {
                $(".favor-icon").hide();
                $(".favor-restaurant").show()
            }
        });
        var a = function(e, f) {
            var d = no_cache_url(get_entry_url() + "/entry/favorRestaurant");
            $.post(d, {
                entry_id: dianexia.entry_id,
                restaurant_id: e
            },
            function(g) {
                if (typeof f != "undefined") {
                    f(g)
                }
            })
        };
        var c = function(e, f) {
            var d = no_cache_url(get_entry_url() + "/entry/unFavorRestaurant");
            $.post(d, {
                entry_id: dianexia.entry_id,
                restaurant_id: e
            },
            function(g) {
                if (typeof f != "undefined") {
                    f(g)
                }
            })
        };
        $(".favor-restaurant").live("click",
        function() {
            if (!login_modal_first()) {
                return false
            }
            var d = $(this);
            a(restaurant_id,
            function(e) {
                $(".favor-icon").show();
                d.hide();
                d.next().show()
            });
            return false
        });
        $(".un-favor-restaurant").live("click",
        function() {
            if (!login_modal_first()) {
                return false
            }
            var d = $(this);
            c(restaurant_id,
            function(e) {
                $(".favor-icon").hide();
                d.prev().show();
                d.hide()
            });
            return false
        })
    })(); (function() {
        if ($(".huanbao-week-order").size() >= 1) {
            var b = no_cache_url(get_entry_url() + "/restaurant/week_order");
            var a = $(".huanbao-week-order").attr("rel");
            var c = $(".huanbao-week-order");
            $.get(b, {
                id: a
            },
            function(d) {
                c.find(".line-one").html(d)
            })
        }
    })()
});
$(function() {
    if (!ma || ma != "restaurant/show" || tab != "menu") {
        return false
    } (function() {
        if ($(".restaurant-tab-content").size() >= 1) {
            var a = $(".food-category-selector");
            $(".food-category-selector").show();
            $(".trigger").click(function() {
                if ($(this).next().is(":visible")) {
                    $(this).next().hide();
                    $(this).show();
                    a.css({
                        marginLeft: 0 - 25
                    })
                } else {
                    $(this).hide();
                    $(this).next().show();
                    a.css({
                        marginLeft: 0 - a.width()
                    })
                }
            });
            $("body").click(function(b) {
                if (! ($(b.target).parents().is(".food-category-selector"))) {
                    $(".food-category-selector .list").hide();
                    $(".food-category-selector .trigger").show();
                    a.css({
                        marginLeft: 0 - 25
                    })
                }
            });
            $(".food-category-selector ul li").click(function() {
                var b = $(this).attr("rel");
                $(window).scrollTo($("#food-category-" + b), 800);
                $(".food-category-selector ul li").removeClass("active");
                $(this).addClass("active");
                return false
            })
        }
    })(); (function() {
        $(".menu-category-filter ul li").click(function() {
            $(".menu-category-filter ul li").removeClass("active");
            $(this).addClass("active");
            var a = $(this).attr("rel");
            if (a == "all") {
                $(".food-category").show();
                return false
            }
            $(".food-category").hide();
            $("#food-category-" + a).show();
            return false
        })
    })(); (function() {
        var a = get_entry_url() + "/restaurant/favoredFoods";
        $.getJSON(no_cache_url(a), {
            restaurant_id: restaurant_id
        },
        function(b) {
            $.each(b,
            function(c, d) {
                $("#food-" + d).addClass("favored")
            })
        })
    })(); (function() {
        var a = null;
        $(".food-item").live("mouseenter",
        function() {
            var b = $(this);
            clearTimeout(a);
            a = setTimeout(function() {
                b.find(".extra-action-wrapper").show();
                b.find(".num-ratings").hide();
                if (b.hasClass("favored")) {
                    b.find(".hover-favor-food").hide();
                    b.find(".hover-un-favor-food").show()
                } else {
                    b.find(".hover-favor-food").show();
                    b.find(".hover-un-favor-food").hide()
                }
                b.find(".hover-food-link").show()
            },
            100)
        }).live("mouseleave",
        function() {
            clearTimeout(a);
            $(this).find(".num-ratings").show();
            $(this).find(".extra-action-wrapper").hide();
            $(this).find(".hover-favor-food").hide();
            $(this).find(".hover-un-favor-food").hide();
            $(this).find(".hover-food-link").hide()
        });
        $(".image-food-item").hover(function() {
            $(this).find(".extra-action-wrapper").show();
            $(this).find(".rating-popularity").hide();
            if ($(this).hasClass("favored")) {
                $(this).find(".hover-favor-food").hide();
                $(this).find(".hover-un-favor-food").show()
            } else {
                $(this).find(".hover-favor-food").show();
                $(this).find(".hover-un-favor-food").hide()
            }
            $(this).find(".hover-food-link").show()
        },
        function() {
            $(this).find(".extra-action-wrapper").hide();
            $(this).find(".rating-popularity").show();
            $(this).find(".hover-favor-food").hide();
            $(this).find(".hover-un-favor-food").hide();
            $(this).find(".hover-food-link").hide()
        })
    })(); (function() {
        $(".hover-favor-food").live("click",
        function() {
            if (!login_modal_first()) {
                return false
            }
            var b = $(this);
            var c = b.attr("rel");
            var a = get_entry_url() + "/food/favor";
            $.get(no_cache_url(a), {
                food_id: c,
                restaurant_id: restaurant_id
            },
            function(d) {
                if (d >= 1) {
                    b.hide();
                    b.next().show();
                    $("#food-" + c).addClass("favored")
                }
            });
            return false
        });
        $(".hover-un-favor-food").live("click",
        function() {
            if (!login_modal_first()) {
                return false
            }
            var b = $(this);
            var c = b.attr("rel");
            var a = get_entry_url() + "/food/unfavor";
            $.get(no_cache_url(a), {
                food_id: c,
                restaurant_id: restaurant_id
            },
            function(d) {
                if (d >= 1) {
                    b.hide();
                    b.prev().show();
                    $("#food-" + c).removeClass("favored")
                }
            });
            return false
        })
    })();
    $(".tooltip-on").tooltip()
});
$(function() {
    if (!ma || ma != "restaurant/show" || tab != "menu") {
        return false
    }
    if (typeof restaurant_has_activity_half_price == "undefined" || !restaurant_has_activity_half_price) {
        return false
    }
    function a() {
        var b = get_entry_url() + "/restaurant/tuesday_half_price_foods";
        $.get(b, {
            id: restaurant_id
        },
        function(c) {
            if (c) {
                $dom = $(c);
                $(".restaurant-tab-content .menu").prepend($dom);
                $dom.slideDown("slow")
            }
        })
    } (function() {
        setTimeout(function() {
            a()
        },
        500)
    })()
});